package com.wlr.study.leetcode;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;

public class LeetCode205 {
    public static boolean isIsomorphic(String s, String t) {
        HashMap<Character, Character> sMap = new HashMap<>();
        HashMap<Character, Character> tMap = new HashMap<>();
        if (s.length() != t.length()) {
            return false;
        }
        for (int i = 0; i < s.length(); i++) {
            if (sMap.containsKey(s.charAt(i))&&sMap.get(s.charAt(i))!=t.charAt(i)||tMap.containsKey(t.charAt(i))&&tMap.get(t.charAt(i))!=s.charAt(i)){
                return false;
            }
            sMap.put(s.charAt(i), t.charAt(i));
            tMap.put(t.charAt(i), s.charAt(i));
        }
        return true;
    }

    public static void main(String[] args) {
        System.out.println(LeetCode205.isIsomorphic("paper", "title"));
    }
}
